home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / MenuAdapter.js621 < prev    next >
Text File  |  2006-09-20  |  5KB  |  128 lines

  1. ∩╗┐var hoverClass = "AspNet-Menu-Hover";
  2. var topmostClass = "AspNet-Menu";
  3. var userAgent = navigator.userAgent;
  4. var versionOffset = userAgent.indexOf("MSIE");
  5. var isIE = (versionOffset >= 0);
  6. var isPreIE7 = false;
  7. var fullVersionIE = "";
  8. var majorVersionIE = "";
  9. if (isIE)
  10. {
  11.     fullVersionIE = parseFloat(userAgent.substring(versionOffset+5, userAgent.length));
  12.     majorVersionIE = parseInt('' + fullVersionIE);
  13.     isPreIE7 = majorVersionIE < 7;
  14. }
  15.  
  16. function Hover__AspNetMenu(element)
  17. {
  18.     AddClass__CssFriendlyAdapters(element, hoverClass);
  19.  
  20.     if (isPreIE7)
  21.     {
  22.         var child = element.firstChild;
  23.         while (child)
  24.         {
  25.             if (child.tagName == "UL")
  26.             {
  27.                 var grandchild = child.firstChild;
  28.                 while (grandchild)
  29.                 {
  30.                     if (grandchild.tagName == "LI")
  31.                     {
  32.                         if ((typeof(grandchild.iFrameFormElementMask) != "undefined") && (grandchild.iFrameFormElementMask != null))
  33.                         {
  34.                             grandchild.iFrameFormElementMask.style.display = "block";
  35.                             
  36.                             var w = grandchild.offsetWidth;
  37.                             if ((grandchild.offsetWidth == 0) && (typeof(element.iFrameFormElementMask) != "undefined") && (element.iFrameFormElementMask != null) && (element.iFrameFormElementMask.style.width.length > 0))
  38.                             {
  39.                                 w = element.iFrameFormElementMask.style.width;
  40.                             }
  41.                             grandchild.iFrameFormElementMask.style.width = w;
  42.                             
  43.                             var h = grandchild.offsetHeight + 5 /* fudge to cover margins between menu items */;
  44.                             if ((grandchild.offsetHeight == 0) && (typeof(element.iFrameFormElementMask) != "undefined") && (element.iFrameFormElementMask != null) && (element.iFrameFormElementMask.style.height.length > 0))
  45.                             {
  46.                                 h = element.iFrameFormElementMask.style.height;
  47.                             }
  48.                             grandchild.iFrameFormElementMask.style.height = h;
  49.                         }
  50.                     }
  51.                     
  52.                     grandchild = grandchild.nextSibling;
  53.                 }
  54.             }
  55.  
  56.             child = child.nextSibling;
  57.         }
  58.     }
  59. }
  60.  
  61. function Unhover__AspNetMenu(element)
  62. {
  63.     RemoveClass__CssFriendlyAdapters(element, hoverClass);
  64.  
  65.     if (isPreIE7)
  66.     {
  67.         var child = element.firstChild;
  68.         while (child)
  69.         {
  70.             if (child.tagName == "UL")
  71.             {
  72.                 var grandchild = child.firstChild;
  73.                 while (grandchild)
  74.                 {
  75.                     if (grandchild.tagName == "LI")
  76.                     {
  77.                         if ((typeof(grandchild.iFrameFormElementMask) != "undefined") && (grandchild.iFrameFormElementMask != null))
  78.                         {
  79.                             grandchild.iFrameFormElementMask.style.display = "none";
  80.                         }
  81.                     }
  82.  
  83.                     grandchild = grandchild.nextSibling;
  84.                 }
  85.             }
  86.  
  87.             child = child.nextSibling;
  88.         }
  89.     }
  90. }
  91.  
  92. function SetHover__AspNetMenu()
  93. {
  94.     var menus = document.getElementsByTagName("ul");
  95.     for (var i=0; i<menus.length; i++)
  96.     {
  97.         if(menus[i].className == topmostClass)
  98.         {
  99.             var items = menus[i].getElementsByTagName("li");
  100.             for (var k=0; k<items.length; k++)
  101.             {
  102.                 items[k].onmouseover = function() { Hover__AspNetMenu(this); }
  103.                 items[k].onmouseout = function() { Unhover__AspNetMenu(this); }
  104.                 
  105.                 if (isPreIE7 && ((typeof(items[k].iFrameFormElementMask) == "undefined") || (items[k].iFrameFormElementMask == null)))
  106.                 {
  107.                     var iFrameFormElementMask = document.createElement("IFRAME");
  108.                     iFrameFormElementMask.scrolling= "no";
  109.                     iFrameFormElementMask.src = "javascript:false;";
  110.                     iFrameFormElementMask.frameBorder = 0;
  111.                     iFrameFormElementMask.style.display = "none";
  112.                     iFrameFormElementMask.style.position = "absolute";
  113.                     iFrameFormElementMask.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
  114.  
  115.                     iFrameFormElementMask.style.zIndex = -1;
  116.                     items[k].insertBefore(iFrameFormElementMask, items[k].firstChild);
  117.                     items[k].iFrameFormElementMask = iFrameFormElementMask;
  118.                 }                
  119.             }
  120.         }
  121.     }
  122. }
  123.  
  124. if (isPreIE7)
  125. {
  126.     window.onload = SetHover__AspNetMenu;
  127. }
  128.